<?xml version="1.0" encoding="UTF-8" ?>
<mapper namespace="${package.mapper}.${table.mapper}">

    <insert id="insert" parameterType="${package.model}.${table.entity}">
        INSERT INTO ${table.lowerCaseEntity}
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="description != null and description != ''">description,</if>
        </trim>
        <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="description != null and description != ''">#{description},</if>
        </trim>
    </insert>

    <update id="updateById" parameterType="${package.model}.${table.entity}">
        UPDATE ${table.lowerCaseEntity}
        <set>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="description != null and description != ''">description = #{description},</if>
        </set>
        WHERE id = #{id}
    </update>

    <delete id="deleteById" parameterType="long">
        DELETE FROM ${table.lowerCaseEntity} WHERE id = #{id}
    </delete>

    <select id="selectById" parameterType="long" resultType="${package.model}.${table.entity}">
        SELECT * FROM ${table.lowerCaseEntity} WHERE id = #{id}
    </select>

    <select id="selectList" resultType="${package.model}.${table.entity}">
        SELECT * FROM ${table.lowerCaseEntity}
    </select>
</mapper>
